package com.demo2do.fms.admin.dao.supplier;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Limit;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.demo2do.fms.entity.appraisal.AppraisalTemplate;
import com.demo2do.fms.entity.authority.Branch;
import com.demo2do.fms.entity.supplier.common.Supplier;

/**
 *
 * @author houtao
 *
 */
@Dao("hibernate")
public interface AppraisalTemplateDao {
    
    /**
     * @param adminCreate
     * @return
     */
    @Query("SELECT COUNT(*) FROM AppraisalTemplate WHERE disabled = false AND adminCreate = :adminCreate")
    public int count(@Variable("adminCreate") boolean adminCreate);
    
    /**
     * @param branch
     * @return
     */
    @Query("SELECT COUNT(*) FROM AppraisalTemplate WHERE disabled = false AND branch = :branch")
    public int count(@Variable("branch") Branch branch);
    
    /**
     * @param supplier
     * @return
     */
    @Query("SELECT COUNT(*) FROM AppraisalTemplate WHERE disabled = false AND supplier = :supplier")
    public int count(@Variable("supplier") Supplier supplier);
    
    /**
     * @param adminCreate
     * @return
     */
    @Query("FROM AppraisalTemplate WHERE disabled = false AND adminCreate = :adminCreate")
    public List<AppraisalTemplate> list(@Variable("adminCreate") boolean adminCreate);
    
    /**
     * @param adminCreate
     * @param benginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM AppraisalTemplate WHERE disabled = false AND adminCreate = :adminCreate ORDER BY createTime ASC")
    public List<AppraisalTemplate> list(@Variable("adminCreate") boolean adminCreate, @Variable("beginIndex")int benginIndex, @Variable("maxResult")int maxResult);
    
    /**
     * @param branch
     * @return
     */
    @Query("FROM AppraisalTemplate WHERE disabled = false AND branch = :branch")
    public List<AppraisalTemplate> list(@Variable("branch") Branch branch);
    
    /**
     * @param branch
     * @param benginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM AppraisalTemplate WHERE disabled = false AND branch = :branch ORDER BY createTime ASC")
    public List<AppraisalTemplate> list(@Variable("branch") Branch branch, @Variable("beginIndex")int benginIndex, @Variable("maxResult")int maxResult);
    
    /**
     * @param supplier
     * @return
     */
    @Query("FROM AppraisalTemplate WHERE disabled = false AND supplier = :supplier")
    public List<AppraisalTemplate> list(@Variable("supplier") Supplier supplier);
    
    /**
     * @param supplier
     * @param benginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM AppraisalTemplate WHERE disabled = false AND supplier = :supplier ORDER BY createTime ASC")
    public List<AppraisalTemplate> list(@Variable("supplier") Supplier supplier, @Variable("beginIndex")int benginIndex, @Variable("maxResult")int maxResult);
    
    /**
     * @param benginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM AppraisalTemplate WHERE disabled = false")
    public List<AppraisalTemplate> list(@Variable("beginIndex")int benginIndex, @Variable("maxResult")int maxResult);

    /**
     * @param name
     * @return
     */
    @Query("FROM AppraisalTemplate WHERE disabled = false AND name = :name")
    public AppraisalTemplate getByName(@Variable("name") String name);
}
